package com.example.l_crm.controller;

import com.example.l_crm.facade.BaseFacade;
import com.example.l_crm.model.ParmJsonModel;
import com.example.l_crm.model.ReturnVO;
import com.example.l_crm.util.SpringContextUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@Slf4j
public class Rmido {
    @PostMapping("/rmi.do")
    public ReturnVO doBusiness(@RequestBody ParmJsonModel parmJsonModel) {
        log.info("请求参数{}", parmJsonModel);
        String interfaceCode = parmJsonModel.getInterfaceCode();
        ReturnVO returnVO = null;
        if (StringUtils.isNotEmpty(interfaceCode)) {
            BaseFacade facade = (BaseFacade) SpringContextUtil.getBean(interfaceCode);
            returnVO = facade.doBusiness(parmJsonModel);
            returnVO.setInterfaceCode(interfaceCode);
        }
        return returnVO;
    }
}
